/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ee.cybertron.energon.model;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author stevenziggiz
 */
@Entity
@Table(name = "user", catalog = "cybertron", schema = "", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"idProfile"}),
    @UniqueConstraint(columnNames = {"user"})})
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"),
    @NamedQuery(name = "User.findByIduser", query = "SELECT u FROM User u WHERE u.iduser = :iduser"),
    @NamedQuery(name = "User.findByUser", query = "SELECT u FROM User u WHERE u.user = :user"),
    @NamedQuery(name = "User.findByUserPassword", query = "SELECT u FROM User u WHERE u.user = ? AND u.password = ?"),
    @NamedQuery(name = "User.findByPassword", query = "SELECT u FROM User u WHERE u.password = :password")})
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "iduser", nullable = false)
    private Integer iduser;
    @Basic(optional = false)
    @Column(name = "user", nullable = false, length = 45)
    private String user;
    @Basic(optional = false)
    @Column(name = "password", nullable = false, length = 45)
    private String password;
    @JoinColumn(name = "idProfile", referencedColumnName = "idprofile", nullable = false)
    @OneToOne(optional = false, fetch = FetchType.EAGER)
    private Profile idProfile;

    public User() {
    }

    public User(Integer iduser) {
        this.iduser = iduser;
    }

    public User(Integer iduser, String user, String password) {
        this.iduser = iduser;
        this.user = user;
        this.password = password;
    }

    public Integer getIduser() {
        return iduser;
    }

    public void setIduser(Integer iduser) {
        this.iduser = iduser;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Profile getIdProfile() {
        return idProfile;
    }

    public void setIdProfile(Profile idProfile) {
        this.idProfile = idProfile;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iduser != null ? iduser.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof User)) {
            return false;
        }
        User other = (User) object;
        if ((this.iduser == null && other.iduser != null) || (this.iduser != null && !this.iduser.equals(other.iduser))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ee.cybertron.energon.model.User[ iduser=" + iduser + " ]";
    }
    
}
